/*
 * JFrameProfile.java
 *
 * Created on April 30, 2007, 1:01 PM
 */

package info.decamps.m2settings.swing;

import info.decamps.m2settings.beans.MyProfile;
import info.decamps.m2settings.model.PluginRepositoriesTableModel;
import info.decamps.m2settings.model.Profile;
import info.decamps.m2settings.model.ProfilesTableModel;
import info.decamps.m2settings.model.RepositoriesTableModel;
import java.lang.annotation.Annotation;
import org.apache.log4j.Logger;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.ValidationException;

/**
 *
 * @author  regis
 */
public class JFrameProfile extends javax.swing.JFrame {
    private Logger log = Logger.getLogger(JFrameProfile.class);
    
    private ProfilesTableModel model;
    private int index=-1;
    private MyProfile profile;
    
    /** Creates new form JFrameProfile */
    public JFrameProfile(ProfilesTableModel tableModel, int index) {
        this.index=index;
        this.model=tableModel;
        if (index>=0) {
            this.profile=new MyProfile(tableModel.getRow(index));
            setTitle("Edit profile "+profile.getId());
        } else {
            this.profile=new MyProfile();
            setTitle("Configure new profile");
        }
        initComponents();
        
    }
    
    public JFrameProfile(ProfilesTableModel tableModel) {
        this(tableModel,-1);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jTextFieldId = new javax.swing.JTextField();
        jLabelId = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelActivation = new javax.swing.JPanel();
        jCheckBoxActiveByDefault = new javax.swing.JCheckBox();
        jPanelOS = new javax.swing.JPanel();
        jLabelOSName = new javax.swing.JLabel();
        jTextFieldOSName = new javax.swing.JTextField();
        jLabelOS = new javax.swing.JLabel();
        jLabelOSFamily = new javax.swing.JLabel();
        jTextFieldOSFamily = new javax.swing.JTextField();
        jLabelOSArch = new javax.swing.JLabel();
        jLabelOSVersion = new javax.swing.JLabel();
        jTextFieldOSArch = new javax.swing.JTextField();
        jTextFieldOSVersion = new javax.swing.JTextField();
        jPanelJDK = new javax.swing.JPanel();
        jLabelJDK = new javax.swing.JLabel();
        jTextFieldJDK = new javax.swing.JTextField();
        jPanelProperty = new javax.swing.JPanel();
        jLabelProperty = new javax.swing.JLabel();
        jTextFieldPropertyName = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldPropertyValue = new javax.swing.JTextField();
        jPanelFile = new javax.swing.JPanel();
        jLabelFile = new javax.swing.JLabel();
        jButtonFileExists = new javax.swing.JButton();
        jButtonFileMissing = new javax.swing.JButton();
        jTextFieldFileExists = new javax.swing.JTextField();
        jTextFieldFileMissing = new javax.swing.JTextField();
        jPanelProperties = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jEditorPaneProperties = new javax.swing.JEditorPane();
        jPanelRepositories = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableRepositories = new javax.swing.JTable();
        jButtonRepositoryAdd = new javax.swing.JButton();
        jButtonRepositoryEdit = new javax.swing.JButton();
        jButtonRemove = new javax.swing.JButton();
        jPanelPluginrepositories = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTablePluginrepositories = new javax.swing.JTable();
        jButtonPluginrepositoryAdd = new javax.swing.JButton();
        jButtonPluginepositoryEdit = new javax.swing.JButton();
        jButtonPluginremove = new javax.swing.JButton();
        jButtonOK = new javax.swing.JButton();
        jButtonCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jTextFieldId.setText(profile.getId());

        jLabelId.setText("id");

        jTabbedPane1.setToolTipText("");
        jPanelActivation.setToolTipText("The conditions within the build runtime environment which will trigger the automatic inclusion of the parent build profile.");
        jCheckBoxActiveByDefault.setSelected(profile.getActivationIsActiveByDefault());
        jCheckBoxActiveByDefault.setText("active by default");
        jCheckBoxActiveByDefault.setToolTipText("Flag specifying whether this profile is active as a default.");
        jCheckBoxActiveByDefault.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBoxActiveByDefault.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jPanelOS.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanelOS.setToolTipText("Specifies that this profile will be activated when matching OS attributes are detected.");
        jLabelOSName.setText("name");

        jTextFieldOSName.setText(profile.getActivationOSName());
        jTextFieldOSName.setToolTipText("The name of the OS to be used to activate a profile");

        jLabelOS.setText("OS");

        jLabelOSFamily.setText("family");

        jTextFieldOSFamily.setText(profile.getActivationOSFamily());
        jTextFieldOSFamily.setToolTipText("The general family of the OS to be used to activate a profile (e.g. 'windows')");

        jLabelOSArch.setText("arch");

        jLabelOSVersion.setText("version");

        jTextFieldOSArch.setText(profile.getActivationOSArch());
        jTextFieldOSArch.setToolTipText("The architecture of the OS to be used to activate a profile");

        jTextFieldOSVersion.setText(profile.getActivationOSVersion());
        jTextFieldOSVersion.setToolTipText("The version of the OS to be used to activate a profile");

        org.jdesktop.layout.GroupLayout jPanelOSLayout = new org.jdesktop.layout.GroupLayout(jPanelOS);
        jPanelOS.setLayout(jPanelOSLayout);
        jPanelOSLayout.setHorizontalGroup(
            jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelOSLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanelOSLayout.createSequentialGroup()
                        .add(jLabelOS)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabelOSName)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldOSName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE))
                    .add(jPanelOSLayout.createSequentialGroup()
                        .add(jLabelOSFamily)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldOSFamily, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))
                    .add(jPanelOSLayout.createSequentialGroup()
                        .add(jLabelOSArch)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldOSArch, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE))
                    .add(jPanelOSLayout.createSequentialGroup()
                        .add(jLabelOSVersion)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldOSVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelOSLayout.setVerticalGroup(
            jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelOSLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelOS)
                    .add(jLabelOSName)
                    .add(jTextFieldOSName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelOSFamily)
                    .add(jTextFieldOSFamily, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelOSArch)
                    .add(jTextFieldOSArch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelOSLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelOSVersion)
                    .add(jTextFieldOSVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelJDK.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabelJDK.setText("JDK");

        jTextFieldJDK.setText(profile.getActivationJDK());
        jTextFieldJDK.setToolTipText("Specifies that this profile will be activated when a matching JDK is detected.");

        org.jdesktop.layout.GroupLayout jPanelJDKLayout = new org.jdesktop.layout.GroupLayout(jPanelJDK);
        jPanelJDK.setLayout(jPanelJDKLayout);
        jPanelJDKLayout.setHorizontalGroup(
            jPanelJDKLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelJDKLayout.createSequentialGroup()
                .addContainerGap()
                .add(jLabelJDK)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTextFieldJDK, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanelJDKLayout.setVerticalGroup(
            jPanelJDKLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelJDKLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelJDKLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelJDK)
                    .add(jTextFieldJDK, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelProperty.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanelProperty.setToolTipText("This is the property specification used to activate a profile. If the value field is empty, then the existence of the named property will activate the profile, otherwise it does a case-sensitive match against the property value as well.");
        jLabelProperty.setText("property");

        jTextFieldPropertyName.setText(profile.getActivationPropertyName());
        jTextFieldPropertyName.setToolTipText("The name of the property to be used to activate a profile");

        jLabel1.setText("value");

        jTextFieldPropertyValue.setText(profile.getActivationPropertyValue());
        jTextFieldPropertyValue.setToolTipText("The value of the property to be used to activate a profile");

        org.jdesktop.layout.GroupLayout jPanelPropertyLayout = new org.jdesktop.layout.GroupLayout(jPanelProperty);
        jPanelProperty.setLayout(jPanelPropertyLayout);
        jPanelPropertyLayout.setHorizontalGroup(
            jPanelPropertyLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelPropertyLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelPropertyLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jTextFieldPropertyName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                    .add(jLabelProperty)
                    .add(jLabel1)
                    .add(jTextFieldPropertyValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelPropertyLayout.setVerticalGroup(
            jPanelPropertyLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelPropertyLayout.createSequentialGroup()
                .addContainerGap()
                .add(jLabelProperty)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTextFieldPropertyName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTextFieldPropertyValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jPanelFile.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanelFile.setToolTipText("This is the file specification used to activate a profile. The missing value will be a the location of a file that needs to exist, and if it doesn't the profile must run. On the other hand exists will test for the existence of the file and if it is there will run the profile.");
        jLabelFile.setText("File");

        jButtonFileExists.setText("exists");

        jButtonFileMissing.setText("missing");

        jTextFieldFileExists.setText(profile.getActivationFileExists());

        jTextFieldFileMissing.setText(profile.getActivationFileMissing());

        org.jdesktop.layout.GroupLayout jPanelFileLayout = new org.jdesktop.layout.GroupLayout(jPanelFile);
        jPanelFile.setLayout(jPanelFileLayout);
        jPanelFileLayout.setHorizontalGroup(
            jPanelFileLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelFileLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelFileLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabelFile)
                    .add(jPanelFileLayout.createSequentialGroup()
                        .add(jButtonFileExists)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldFileExists, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE))
                    .add(jPanelFileLayout.createSequentialGroup()
                        .add(jButtonFileMissing)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldFileMissing, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelFileLayout.setVerticalGroup(
            jPanelFileLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelFileLayout.createSequentialGroup()
                .addContainerGap()
                .add(jLabelFile)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelFileLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonFileExists)
                    .add(jTextFieldFileExists, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelFileLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonFileMissing)
                    .add(jTextFieldFileMissing, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout jPanelActivationLayout = new org.jdesktop.layout.GroupLayout(jPanelActivation);
        jPanelActivation.setLayout(jPanelActivationLayout);
        jPanelActivationLayout.setHorizontalGroup(
            jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelActivationLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanelFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanelActivationLayout.createSequentialGroup()
                        .add(jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanelProperty, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jCheckBoxActiveByDefault))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanelOS, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jPanelJDK, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanelActivationLayout.setVerticalGroup(
            jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelActivationLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanelJDK, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jCheckBoxActiveByDefault))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelActivationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanelProperty, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanelOS, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );
        jTabbedPane1.addTab("activation", jPanelActivation);

        jPanelProperties.setToolTipText("Extended configuration specific to this profile goes here. Contents take the form of property.");
        jEditorPaneProperties.setText(profile.getProperties());
        jEditorPaneProperties.setToolTipText("Extended configuration specific to this profile goes here. Contents take the form of property.");
        jScrollPane1.setViewportView(jEditorPaneProperties);

        org.jdesktop.layout.GroupLayout jPanelPropertiesLayout = new org.jdesktop.layout.GroupLayout(jPanelProperties);
        jPanelProperties.setLayout(jPanelPropertiesLayout);
        jPanelPropertiesLayout.setHorizontalGroup(
            jPanelPropertiesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelPropertiesLayout.createSequentialGroup()
                .add(56, 56, 56)
                .add(jScrollPane1)
                .addContainerGap())
        );
        jPanelPropertiesLayout.setVerticalGroup(
            jPanelPropertiesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelPropertiesLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                .addContainerGap())
        );
        jTabbedPane1.addTab("properties", jPanelProperties);

        jPanelRepositories.setToolTipText("The lists of the remote repositories");
        jScrollPane2.setToolTipText("The lists of the remote repositories");
        jTableRepositories.setModel(new RepositoriesTableModel(profile.getRepositories()));
        jScrollPane2.setViewportView(jTableRepositories);

        jButtonRepositoryAdd.setText("Add");
        jButtonRepositoryAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRepositoryAddActionPerformed(evt);
            }
        });

        jButtonRepositoryEdit.setText("Edit");
        jButtonRepositoryEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRepositoryEditActionPerformed(evt);
            }
        });

        jButtonRemove.setText("Remove");

        org.jdesktop.layout.GroupLayout jPanelRepositoriesLayout = new org.jdesktop.layout.GroupLayout(jPanelRepositories);
        jPanelRepositories.setLayout(jPanelRepositoriesLayout);
        jPanelRepositoriesLayout.setHorizontalGroup(
            jPanelRepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelRepositoriesLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelRepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .add(jPanelRepositoriesLayout.createSequentialGroup()
                        .add(jButtonRepositoryAdd)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButtonRepositoryEdit)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 278, Short.MAX_VALUE)
                        .add(jButtonRemove)))
                .addContainerGap())
        );
        jPanelRepositoriesLayout.setVerticalGroup(
            jPanelRepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelRepositoriesLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelRepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonRepositoryAdd)
                    .add(jButtonRepositoryEdit)
                    .add(jButtonRemove))
                .addContainerGap())
        );
        jTabbedPane1.addTab("repositories", jPanelRepositories);

        jPanelPluginrepositories.setToolTipText("The lists of the remote repositories for discovering plugins");
        jScrollPane3.setToolTipText("The lists of the remote repositories for discovering plugins");
        jTablePluginrepositories.setModel(new PluginRepositoriesTableModel(profile.getPluginrepositories()));
        jScrollPane3.setViewportView(jTablePluginrepositories);

        jButtonPluginrepositoryAdd.setText("Add");
        jButtonPluginrepositoryAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPluginrepositoryAddActionPerformed(evt);
            }
        });

        jButtonPluginepositoryEdit.setText("Edit");
        jButtonPluginepositoryEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPluginepositoryEditActionPerformed(evt);
            }
        });

        jButtonPluginremove.setText("Remove");

        org.jdesktop.layout.GroupLayout jPanelPluginrepositoriesLayout = new org.jdesktop.layout.GroupLayout(jPanelPluginrepositories);
        jPanelPluginrepositories.setLayout(jPanelPluginrepositoriesLayout);
        jPanelPluginrepositoriesLayout.setHorizontalGroup(
            jPanelPluginrepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelPluginrepositoriesLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelPluginrepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .add(jPanelPluginrepositoriesLayout.createSequentialGroup()
                        .add(jButtonPluginrepositoryAdd)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButtonPluginepositoryEdit)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 278, Short.MAX_VALUE)
                        .add(jButtonPluginremove)))
                .addContainerGap())
        );
        jPanelPluginrepositoriesLayout.setVerticalGroup(
            jPanelPluginrepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelPluginrepositoriesLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelPluginrepositoriesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonPluginrepositoryAdd)
                    .add(jButtonPluginepositoryEdit)
                    .add(jButtonPluginremove))
                .addContainerGap())
        );
        jTabbedPane1.addTab("plugin repositories", jPanelPluginrepositories);

        jButtonOK.setText("OK");
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });

        jButtonCancel.setText("Cancel");
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(jLabelId)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .add(jButtonCancel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 385, Short.MAX_VALUE)
                        .add(jButtonOK)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelId)
                    .add(jTextFieldId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonOK)
                    .add(jButtonCancel))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void jButtonPluginepositoryEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPluginepositoryEditActionPerformed
        JFrameRepository repoWin=new JFrameRepository((PluginRepositoriesTableModel)jTablePluginrepositories.getModel(),
                jTablePluginrepositories.getSelectedRow());
        repoWin.setVisible(true);
    }//GEN-LAST:event_jButtonPluginepositoryEditActionPerformed
    
    private void jButtonPluginrepositoryAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPluginrepositoryAddActionPerformed
        JFrameRepository repoWin=new JFrameRepository((PluginRepositoriesTableModel)jTablePluginrepositories.getModel(),
                jTablePluginrepositories.getSelectedRow());
        repoWin.setVisible(true);
    }//GEN-LAST:event_jButtonPluginrepositoryAddActionPerformed
    
    private void jButtonRepositoryEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRepositoryEditActionPerformed
        JFrameRepository repoWin=new JFrameRepository((RepositoriesTableModel)jTableRepositories.getModel(),
                jTableRepositories.getSelectedRow());
        repoWin.setVisible(true);
    }//GEN-LAST:event_jButtonRepositoryEditActionPerformed
    
    private void jButtonRepositoryAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRepositoryAddActionPerformed
        JFrameRepository repoWin=new JFrameRepository((RepositoriesTableModel)jTableRepositories.getModel());
        repoWin.setVisible(true);
    }//GEN-LAST:event_jButtonRepositoryAddActionPerformed
    
    private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
        try {
            profile.setProperties(jEditorPaneProperties.getText());
            profile.setId(jTextFieldId.getText());
            profile.setActivationByDefault(jCheckBoxActiveByDefault.isSelected());
            profile.setActivationJDK(jTextFieldJDK.getText());
            profile.setActivationFileExists(jTextFieldFileExists.getText());
            profile.setActivationFileMissing(jTextFieldFileMissing.getText());
            profile.setActivationProperty(jTextFieldPropertyName.getText(),jTextFieldPropertyValue.getText());
            profile.setActivationOS(jTextFieldOSName.getText(),
                    jTextFieldOSFamily.getText(),
                    jTextFieldOSArch.getText(),
                    jTextFieldOSVersion.getText());
            profile.setRepositories(
                    ( (RepositoriesTableModel)jTableRepositories.getModel() )
                    .getRepositories());
            profile.setPluginRepositories(
                    ( (PluginRepositoriesTableModel)jTablePluginrepositories.getModel())
                    .getPluginRepositories());
            if(index<0) {
                log.debug("new profile added");
                model.addRow(profile.getProfile());
            } else {
                log.debug("profile configuration changed");
                model.fireChange(index);
            }
            dispose();
        } catch (ValidationException ex) {
            ex.printStackTrace();
        } catch (MarshalException ex) {
            ex.printStackTrace();
        }
        
    }//GEN-LAST:event_jButtonOKActionPerformed
    
    private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonCancelActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ProfilesTableModel m=new ProfilesTableModel(null);
                new JFrameProfile(m).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonFileExists;
    private javax.swing.JButton jButtonFileMissing;
    private javax.swing.JButton jButtonOK;
    private javax.swing.JButton jButtonPluginepositoryEdit;
    private javax.swing.JButton jButtonPluginremove;
    private javax.swing.JButton jButtonPluginrepositoryAdd;
    private javax.swing.JButton jButtonRemove;
    private javax.swing.JButton jButtonRepositoryAdd;
    private javax.swing.JButton jButtonRepositoryEdit;
    private javax.swing.JCheckBox jCheckBoxActiveByDefault;
    private javax.swing.JEditorPane jEditorPaneProperties;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelFile;
    private javax.swing.JLabel jLabelId;
    private javax.swing.JLabel jLabelJDK;
    private javax.swing.JLabel jLabelOS;
    private javax.swing.JLabel jLabelOSArch;
    private javax.swing.JLabel jLabelOSFamily;
    private javax.swing.JLabel jLabelOSName;
    private javax.swing.JLabel jLabelOSVersion;
    private javax.swing.JLabel jLabelProperty;
    private javax.swing.JPanel jPanelActivation;
    private javax.swing.JPanel jPanelFile;
    private javax.swing.JPanel jPanelJDK;
    private javax.swing.JPanel jPanelOS;
    private javax.swing.JPanel jPanelPluginrepositories;
    private javax.swing.JPanel jPanelProperties;
    private javax.swing.JPanel jPanelProperty;
    private javax.swing.JPanel jPanelRepositories;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTablePluginrepositories;
    private javax.swing.JTable jTableRepositories;
    private javax.swing.JTextField jTextFieldFileExists;
    private javax.swing.JTextField jTextFieldFileMissing;
    private javax.swing.JTextField jTextFieldId;
    private javax.swing.JTextField jTextFieldJDK;
    private javax.swing.JTextField jTextFieldOSArch;
    private javax.swing.JTextField jTextFieldOSFamily;
    private javax.swing.JTextField jTextFieldOSName;
    private javax.swing.JTextField jTextFieldOSVersion;
    private javax.swing.JTextField jTextFieldPropertyName;
    private javax.swing.JTextField jTextFieldPropertyValue;
    // End of variables declaration//GEN-END:variables
    
}
